refactor: AI features cleanup wave 2 (chat tools, providers, HIG)#1113
Merged
refactor: AI features cleanup wave 2 (chat tools, providers, HIG)#1113
Conversation
…nnectionId helper
…log truncated bodies
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Wave 2 of the AI features audit (follow-up to #1111). 5 commits, all scoped, all conventional. Production builds clean, AI tests pass.
What changed
Chat tool schemas (
refactor(ai-chat): extract ChatToolSchemaBuilder...): introducedChatToolSchemaBuilderwith composable builders (object,string,enumString,boolean,integer) and named constants (connectionId,databaseName,schemaName,tableName). All 9 tools now express theirinputSchemain 1-2 lines instead of 10-15. LiftedresolveConnectionIdfrom a free function inGetConnectionStatusChatTooltoChatToolContext+Helpers.swiftso every tool callscontext.resolveConnectionId(input). Net -98 LOC across the tool files.Mention detection Unicode safety (
fix(ai-chat): handle non-BMP characters...):MentionDetectorwalked NSString UTF-16 units, so an@placed right after an emoji or other non-BMP scalar saw a low surrogate first and produced a malformed query. Rewritten to walkString.UnicodeScalarViewbackward viaString.Index, replaced the magic0x40withUnicode.Scalar(\"@\"). Added regression tests for emoji-before-trigger, emoji-inside-query, and non-BMP-after-caret cases.Tool mode declaration (
refactor(ai-chat): declare per-tool mode...): addedChatToolMode { readOnly, write, agentOnly }to theChatToolprotocol. Each tool declares its own mode. The registry no longer carries hardcodedreadOnlyToolNames/editModeToolNamessets, so adding a tool toChatToolBootstrapis now sufficient for it to participate inAsk/Edit/Agentmodes correctly.Provider polish (
refactor(ai-providers): refresh known models...): AnthropictestConnection()uses the configured model withknownModels.firstfallback (no more pinnedclaude-haiku-4-5-20251001). RefreshedknownModelsto includeclaude-opus-4-7-20260101andclaude-sonnet-4-6-20251101.AIProvider.collectErrorBody()logs an OSLog warning when it truncates at 2000 bytes (previously silent). Ollama detector now logs the URLError code or generic error type instead of swallowing every failure as 'not running'.HIG alignment (
refactor(hig): align AI chat views...):.background(.quaternary, in: RoundedRectangle(cornerRadius: 6))on tool-use and tool-result block headers..tint.opacity(0.08)fill and 0.5pt stroke (macOS divider weight)..alternateSelectedControlTextColor(canonical AppKit foreground forselectedContentBackgroundColor), no moreColor.whitethat fails contrast in dark mode..em(...)relative sizing (1.0 body, 1.15/1.3/1.5 for h3/h2/h1) so Dynamic Type works.MessageView,ContextChipView,MentionSuggestionListView.Color(nsColor: .systemYellow)because.yellow.tertiaryis macOS 15+ and the deployment target is 14.0)..accessibilityLabelto icon-only buttons: scroll-to-latest, edit pencil, send, stop, mention@menu, slash-command menu.Files
git diff main...HEAD --statfor the breakdown)Critical: not touched
IntelligenceFocusBorderandIntelligenceShimmerinChatComposerView.swiftare intentional. They mimic Apple Intelligence's animated gradient stroke around AI input fields (Writing Tools, Image Playground, Siri border), which is the post-Sequoia native HIG pattern for AI surfaces. Wave 1 reverted an over-eager removal of these in commit0d78c126.Test plan
xcodebuild buildgreen for the production target across all 5 commitsswiftlint lint --strictclean on every touched fileMentionDetectorTests,ChatToolRegistryTests,ChatToolRegistryModeTests,ChatToolArgumentDecoderTests,ChatToolSpecCopilotTests,ExecuteToolUsesTests,AnthropicProviderEncodingTests,AnthropicProviderParserTests,AIProviderErrorTests,AIProviderFactoryResolveTestsOut of scope (Wave 3)
The audit roadmap is now mostly closed. Remaining items if desired later:
OpenTableTabTestsassertion atMainContentCoordinator+FilterState.swift:311(test fixture issue, not AI code)fixError*MongoDB/Redis test failures (plugin loading in test target)